import Vue from 'vue'
import VueRouter from 'vue-router'


Vue.use(VueRouter)

const routes = [
  {
    path: '/cart',
    name: 'cart',
    component: () => import('../views/Cart.vue'),
    meta: {
      title: '购物车',
      hidderHeader: true,

    }
  },
  {
    path: '/history',
    name: 'history',
    component: () => import('../views/History.vue'),
    meta: {
      title: '历史页面',
    }
  },
  {
    path: '/details',
    name: 'details',
    component: () => import('../views/Details.vue'),
    meta: {
      title: '书详情页',
    }
  },
  {
    path: '/myheader',
    name: 'myheader',
    component: () => import('../components/MyHeader.vue'),
  },
  {
    path: '/myfooter',
    name: 'myfooter',
    component: () => import('../components/MyFooter.vue'),
  },
  {
    path: '*',
    name: '*',
    component: () => import('../views/NotFound.vue'),
  },
  {
    path: '/register',
    name: 'register',
    component: () => import('../views/Register.vue'),
    meta: {
      title: '书城注册',
      hidderHeader: true

    }
  },
  {
    path: '/',
    name: 'index',
    component: () => import('../views/Index.vue'),
    meta: {
      title: '首页-书城',
    }
  },

  {
    path: '/login',
    name: 'login',
    component: () => import('../views/Login.vue'),
    meta: {
      title: '书城登录',
      hidderHeader: true

    }
  },
  // {
  //   path: '/home',
  //   name: 'home',
  //   component: HomeView
  // },
  // {
  //   path: '/about',
  //   name: 'about',
  //   component: () => import('../views/AboutView.vue')
  // }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

router.beforeEach((to, from, next) => {
  document.title = to.meta.title
  next()
})
export default router
